/* ---------------------------------------------------------------------------------------------
 *
 *            Capital Alliance Software Confidential Proprietary
 *            (c) Copyright CAS 201{x}, All Rights Reserved
 *                          www.pekall.com
 *
 * ----------------------------------------------------------------------------------------------
 */
package com.pekall.todo.util;

import android.content.Context;
import android.content.SharedPreferences;
import android.widget.Toast;

public class ShareUtil {
	
	private final String PREFILENAME = "todo";
	
	private Context nContext;
	
	private  SharedPreferences nSharedPreferences;
	
	public ShareUtil(Context context){
		nContext = context;
		nSharedPreferences = context.getSharedPreferences(PREFILENAME, Context.MODE_PRIVATE);
	}
	public void showMessage(String message){
		Toast.makeText(nContext, message, Toast.LENGTH_LONG).show();
	}
	public  void saveInt(String key,int value){
		nSharedPreferences.edit().putInt(key, value).commit();
	}
	public   int getInt(String key,int... defValue){
		if(defValue.length>0)
			return nSharedPreferences.getInt(key, defValue[0]);
		else
		{	
			return nSharedPreferences.getInt(key, 0);
		}
	}
	
	public static String  getLeftString (String s,String separater){
		int indexOf = s.indexOf(separater);
		if(indexOf > -1)
			return s.substring(0, indexOf);
		else
			return s;
	}
	public  void saveSortKeyValue(int which){
		saveInt("sort_key", which);
	}
	
	
	
	

}
